<?php
require_once './admin-header.php';
require_once './core/admin-sql.php';
$sql = new AdminSql();
?>
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=0,maximum-scale=1.0"/>
        <title>我的报名</title>
        <link rel="stylesheet" href="../css/base.css">
        <link rel="stylesheet" href="../css/index.css">

        <script>
            function adapte() {//适配
                var designWidth = 1080, rem2px = 100;
                document.documentElement.style.fontSize = window.innerWidth / designWidth * rem2px + "px";
            }
            adapte();
        </script>
        <style>
        </style>
    </head>
    <body>
    <div class="my-apply1">
        <ul class="list">
            <?php
            $i = 0;
            list($static, $all_array) = $sql->searchPosters($i, $_SESSION['uid']);
            $count = count($all_array);
            if ($count === 0) {
                echo '<li style="text-align: center;">无报名表</li>';
            }
            date_default_timezone_set('PRC');
            $new_all_array = [];
            $array_line = 0;
            $same = [];
            for ($j = 0; $j < $count; $j++) {
                $mark_time = 0;
                $createTime = $all_array[$j][2];
                if ($j == 0) {
                    $new_all_array[$array_line][] = $createTime;
                }
                $lastTime = date('Ymd', $new_all_array[$array_line][0]);
                $thisTime = date('Ymd', $createTime);
                $lastTime = (int)$lastTime;
                $thisTime = (int)$thisTime;
                if ($lastTime == $thisTime) {
                    $new_all_array[$array_line][] = $all_array[$j];
                } else {
                    $array_line++;
                    $new_all_array[$array_line][] = $createTime;
                    $new_all_array[$array_line][] = $all_array[$j];
                }
            }
            $day_count = count($new_all_array);
            for ($i = 0; $i < $day_count; $i++) {
                $time = $new_all_array[$i][0];
                $in_year = date('Y', $time);
                $in_month = date('m', $time);
                $in_day = date('d', $time);
                ?>
                <li class="clearfix">
                    <div class="apply-date tac fl">
                        <p class="day1 b fs60"><?= $in_day ?></p>
                        <p class="day2 fs24"><?= $in_year ?>.<?= $in_month ?></p>
                    </div>
                    <ul class="list1 fr">
                        <?php
                        $in_count = count($new_all_array[$i]) - 1;
                        for ($j = 0; $j < $in_count; $j++) {
                            list($in_taId, $in_title, $in_createTime, $in_poIm) = $new_all_array[$i][$j + 1];
                            if (empty($in_title)) $in_title = '🔥活动火热报名中！！！🔥';
                            if (empty($in_poIm)) $in_poIm = './img/img1.jpg';
                            $makeNum = $sql->posterPosts($in_taId, $_SESSION['uid']);
                            ?>
                            <li class="flex">
                                <p class="list1-l fs40"><?= $in_title ?></p>
                                <div class="list1-r flex">
                                    <a href="myApply2.php?tid=<?= $in_taId ?>"><img src=".<?= $in_poIm ?>" alt="poster"></a>
                                    <p class="apply-num flex">
                                        <span class="fs50 b"><?= $makeNum ?></span>
                                        <span class="fs28">已报名</span>
                                    </p>
                                </div>
                            </li>
                            <?php
                        }
                        ?>
                    </ul>
                </li>
                <?php
            }
            ?>
        </ul>
    </div>
    <script src='../script/jquery.js'></script>
    <script src='../script/index.js'></script>
    </body>
    </html>
<?php
require_once './admin-footer.php';